package com.d0319;

public class EggTest {
    volatile boolean hasEggs=false;
    Thread human =new Thread(()->{
        while (true){
            if (!hasEggs){
                System.out.println("等");

            }else {
                System.out.println("收");
            }
        }
    });
    Thread hen=new Thread(()->{
       while (true){
           try {
               Thread.sleep(3000);
           } catch (InterruptedException e) {
               e.printStackTrace();
           }
           hasEggs=true;
       }
    });

    public static void main(String[] args) {
        EggTest eggTest=new EggTest();
        eggTest.human.start();
        eggTest.hen.start();
    }
}
